package com.atmk.atmk.designMode.创建型.原型模式.demo3.深拷贝;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<String> hobbies = new ArrayList<>();
        hobbies.add("Reading");
        hobbies.add("Cooking");

        Person person1 = new Person();
        person1.setName("Alice");
        person1.setHobbies(hobbies);

        Person person2 = person1.clone();  // 深拷贝

        // 修改 person2 的爱好列表
        person2.getHobbies().add("Gardening");

        System.out.println(person1.getHobbies());  // 输出 [Reading, Cooking]
    }
}
